﻿namespace DimensionsHelper.LanguageService.Syntax;

public class MetadataFieldReference : Declaration
{
    private SyntaxToken? _topLevelToken;

    internal MetadataFieldReference(SyntaxNode? parent, SyntaxToken useKeywordToken,
        Identifier nameIdentifier) :
        base(SyntaxKinds.MetadataFieldReference, useKeywordToken, nameIdentifier, parent)
    {
    }

    public SyntaxToken? TopLevelToken => _topLevelToken;


    public void Update(SyntaxToken topLevelToken)
    {
        SetChildNullableField(ref _topLevelToken, SyntaxToken.IsNullOrEmpty, topLevelToken);
    }


    public override void AcceptVisitor<T>(SyntaxNodeVisitor<T> visitor)
    {
        Accept(visitor, DeclareKeywordToken, NameIdentifier);
    }
}


public static partial class NodeFactory
{
    public static MetadataFieldReference CreateMetadataFieldReference(SyntaxNode? parent,
        SyntaxToken useKeywordToken, Identifier fieldName)
    {
        return new MetadataFieldReference(parent, useKeywordToken, fieldName);
    }
}